using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BuffManager : MonoBehaviour
{
   private readonly List<IBuffs> buffs = new List<IBuffs>();


    public void AddBuff(IBuffs buff)
    {
        buff.OnAdd(gameObject);
        buffs.Add(buff);
    }


    private void Update()
    {
        for (int i = buffs.Count - 1; i >= 0; i--)
        {
            var buff = buffs[i];
            buff.OnUpDate(Time.deltaTime);
            if (buff.IsFinished)
            {
                buff.OnRemove(gameObject);
                buffs.RemoveAt(i);
            }
        }
    }
}
